package com.befiv.lock.springboot.auto.config;

import com.befiv.lock.config.LockAnnotationAdapter;
import com.befiv.lock.config.LockMethodInterceptor;
import com.befiv.lock.modle.Redis;
import com.befiv.lock.redis.RedisLocker;
import com.befiv.lock.redis.RedissonConf;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Gjq
 * @Date: 2019/6/28 0028 上午 10:23
 */
@Configuration
@ConditionalOnProperty(prefix = "spring.redis",name = "lock",matchIfMissing = false)
@EnableConfigurationProperties(Redis.class)
public class RedisLockAutoConfigure {
    @Bean
    @ConditionalOnMissingBean
    public RedissonConf redissonConf(){
        return new RedissonConf();
    }
    @Bean
    @ConditionalOnMissingBean
    public RedisLocker redisLocker(){
        return new RedisLocker();
    }

    @Bean
    @ConditionalOnMissingBean
    public LockMethodInterceptor lockMethodInterceptor(){
        return new LockMethodInterceptor();
    }


    @Bean
    @ConditionalOnMissingBean
    public LockAnnotationAdapter lockAnnotationAdapter(LockMethodInterceptor lockMethodInterceptor){
        return new LockAnnotationAdapter(lockMethodInterceptor);
    }









}
